//带多个懒标记考虑下放顺序
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
using namespace std;
inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
#define endl '\n'
typedef long long LL;
typedef pair<int,int> PII;
const int mod1 = 998244353;
const int N = 1e6 + 10, M = 2 * N;

const LL CC = -0x3f3f3f3f3f3f3f3f;

int arr[N];

struct Node
{
    LL l,r,maxs,cover,add;
}tr[8 * N];

void pushup(int u)
{
    tr[u].maxs = max(tr[u << 1].maxs,tr[u << 1|1].maxs);
}

void build(int u,int l,int r)
{
    if(l == r)
    {
        tr[u] = {l,r,arr[l],CC,0};
    }
    else
    {
        tr[u] = {l,r,0,CC,0};
        int mid = l + r >> 1;
        build(u << 1,l,mid);
        build(u << 1|1,mid + 1,r);
        pushup(u);
    }
}


void pushdown_cover(int u)
{
    auto &root = tr[u],&left = tr[u<<1],&right = tr[u<<1|1];
    
    if(root.cover != CC)
    {
        left.add = 0;
        right.add = 0;
        left.cover = right.cover = root.cover;
        left.maxs = right.maxs = root.cover;
        root.cover = CC;
    }
}

void pushdown_add(int u)
{
    auto &root = tr[u],&left = tr[u<<1],&right = tr[u<<1|1];
    
    if(root.add)
    {
        pushdown_cover(u);
        left.add += root.add;
        left.maxs += root.add;
        right.add += root.add;
        right.maxs += root.add;
        root.add = 0;
    }
}

void pushdown(int u)
{
    pushdown_cover(u);
    pushdown_add(u);
}
void modify_cover(int u,int l,int r,int d)
{
    if(tr[u].l >= l && tr[u].r <= r)
    {
        tr[u].maxs = d;
        tr[u].cover = d;
        tr[u].add = 0;
        return;
    }
    else
    {
        pushdown(u);
        int mid = tr[u].l + tr[u].r >> 1;
        if(l<=mid)
        {
            modify_cover(u<<1,l,r,d);
        }
        if(mid<r)
        {
            modify_cover(u<<1|1,l,r,d);
        }
        pushup(u);
    }
}
void modify_add(int u,int l,int r,int d)
{
    if(tr[u].l >= l && tr[u].r <= r)
    {
        pushdown_cover(u);
        tr[u].maxs += d;
        tr[u].add += d;
        return;
    }
    else
    {
        pushdown(u);
        int mid = tr[u].l + tr[u].r >> 1;
        if(l<=mid)
        {
            modify_add(u<<1,l,r,d);
        }
        if(mid<r)
        {
            modify_add(u<<1|1,l,r,d);
        }
        pushup(u);
    }
}

LL query(int u,int l,int r)
{
    if(tr[u].l>=l&&tr[u].r<=r) return tr[u].maxs;
    
    else
    {
        pushdown(u);
        int mid = tr[u].l + tr[u].r >> 1;
        LL sum = -0x3f3f3f3f3f3f3f3f;
        if(l<=mid) sum = max(sum,query(u<<1,l,r));
        // 如果左儿子代表的区间 [l, mid] 与询问区间有交集, 则递归查询左儿子
        if(mid<r) sum = max(sum,query(u<<1|1,l,r));
        // 如果右儿子代表的区间 [m + 1, r] 与询问区间有交集, 则递归查询右儿子
        return sum;
    } 
}
void solve()
{
    int n;
    cin >> n;
    int q;
    cin >> q;
    for(int i = 1; i <= n; i ++) cin >> arr[i];
    for(int i = 1; i <= N * 8; i ++) tr[i].cover = CC;
    build(1,1,n);
    
    while(q--)
    {
        int op;
        cin >> op;
        if(op == 1)
        {
            int l,r,x;
            cin >> l >> r >> x;
            modify_cover(1,l,r,x);
        }
        else if(op == 2)
        {
            int l,r,x;
            cin >> l >> r >> x;
            modify_add(1,l,r,x);
        }
        else
        {
            
            int l,r;
            cin >> l >> r;
            cout << query(1,l,r) << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tt;
    //cin >> tt;
    tt = 1;
    while(tt --)
    {
        solve();
    }   
}